<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>画布基础</title>
    <style>
        #c1 {
            border: 5px solid black;
        }
    </style>
</head>

<body>
    <canvas id="c1" width="400" height="400"></canvas>
</body>
<script>
    /**
    * @type {HTMLCanvasElement}
    */
    const c1 = document.querySelector("#c1");
    const ctx = c1.getContext("2d");

    //我在中间画一条线
    ctx.moveTo(0,200);
    ctx.lineTo(400,200);
    ctx.stroke();

    //我现在再画一条中间垂直的线
    ctx.beginPath();
    ctx.moveTo(200,0);
    ctx.lineTo(200,400);
    ctx.stroke();


    //我现在在写文字
    ctx.font = "32px 微软雅黑";
    //调整文字垂直的位置
    ctx.textBaseline = "middle";
    //调整文字的水平对齐
    ctx.textAlign = "center";
    ctx.fillText("标哥哥帅气",200,200);

  

</script>

</html>